package de.hska.pwmanager.controller.errors;

import java.util.LinkedList;
import java.util.List;


public class ValidationException extends Exception {
	/**
	 * 
	 */
	private static final long serialVersionUID = 2901740224995651682L;
	private List<ValidationError> errors = new LinkedList<ValidationError>();

	public List<ValidationError> getErrors() {
		return errors;
	}

	public boolean shouldBeThrown() {
		return (this.errors.size() > 0);
	}

	public void addError(ValidationError error) {
		this.errors.add(error);
	}

	public void throwMe() throws ValidationException {
		if(this.shouldBeThrown()) {
			throw this;
		}
	}
	
	public void addAll(ValidationException validationException) {
		this.errors.addAll(validationException.getErrors());
	}
}
